package com.juyu.miliao.authentication.security;

import com.juyu.miliao.common.domain.CommonHead;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class ThirdPartyLoginToken extends UsernamePasswordAuthenticationToken {
    private static final long serialVersionUID = 1106928373472588033L;
    private String accessToken;
    private int type;

    private String ip;


    /**
     * 通用请求头
     */
    private CommonHead commonHead;

    public ThirdPartyLoginToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
        super(principal, credentials, authorities);
    }

    public ThirdPartyLoginToken(Object principal, Object credentials, String accessToken, int type, String ip, CommonHead commonHead) {
        super(principal, credentials);
        if (commonHead == null) {
            throw new RuntimeException("commonHead can not be null");
        }
        this.accessToken = accessToken;
        this.type = type;
        this.ip = ip;
        this.commonHead = commonHead;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public int getType() {
        return type;
    }

    public String getIp() {
        return ip;
    }

    public CommonHead getCommonHead() {
        return commonHead;
    }
}
